<!--
 * @Author: your name
 * @Date: 2022-01-20 13:05:24
 * @LastEditTime: 2022-01-20 13:07:47
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \算法测试\day0906\2029石子游戏.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var stoneGameIX = function (stones) {
            let people = true;
            let num = 0;
            while (true) {
                for (let i = 0; i < stones.length; i++) {
                    if (!((num + stones[i]) % 3 === 0)) {
                        num += stones[i];
                        stones.splice(i, 1);
                        break;
                    } else {
                        if (i === stones.length - 1) {
                            people = !people;
                            console.log(people);
                            return people;
                        }
                    }
                }
                console.log(people);
                if (!stones.length) return false;
                people = !people;
            }
        };
        console.log(stoneGameIX([2,1]));
    </script>
</body>

</html>